# -*- coding: UTF-8 -*-
import random
import os
import commands
import paramiko
cmd = "sudo l2ping -c 10 48:2C:A0:0F:1F:AD"
count = 0
while True:
    print count
    return_code, output = commands.getstatusoutput(cmd)
    if 'Can\'t connect: Host is down' not in output:
        print 'sdadadasd'

    print '-----',output
    if 'Operation not permitted' not in output :
        if 'Can\'t connect: Host is down' not in output:
            ol = output.split('\n')
            err = []
            err.append(ol)
            ln_data = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
            i = 0
            for info in ol:
                if 'time' in info and 'bytes' in info:
                    t = info.split(' ')[7]
                    # print len(t)
                    nt = t[:len(t) - 2]
                    # print nt
                    # if float(nt) > 1000:
                    #     continue
                    ln_data[i] = str(nt)
                    i = i + 1
            wdata = ''
            for nd in ln_data:
                if wdata == '':
                    wdata = nd
                else:
                    wdata = wdata + ' ' + nd
            count = count + 1
            print wdata
    else:
        print '222'
